package cn.bdqn.kaoshi.controller;

import cn.bdqn.kaoshi.pojo.ResponseResult;
import cn.bdqn.kaoshi.pojo.User;
import cn.bdqn.kaoshi.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {

    @Resource
    UserService userService;

    @RequestMapping("/admin/cha")
    @ResponseBody
    public String cha(){
        return "admin角色";
    }

    @RequestMapping("/dba/liang")
    @ResponseBody
    public String liang(){
        return "兩個角色才可以訪問";
    }

    @RequestMapping({"/dba/index","/"})
    public String index(Model model){
        List<User> userAll = userService.findUserAll();
        model.addAttribute("userAll",userAll);
        return "index";
    }

    @RequestMapping("dba/del")
    @ResponseBody
    public ResponseResult del(Integer uid){
        Integer i = userService.delUser(uid);
            return  new ResponseResult(200,"");
    }
}
